Introduction to Robotics: Boe-Bot Servo Control

Running Boe-Bot Backwards

The Scope trace shows the command to turn the rt. servo executes first (Pulsout 12), then the other servo (Pulsout 13). Notice the height of the pulses in the scope trace. When the line is flat it means the voltage =0 and at the height of the pulse, the voltage = 5VDC. This, from the CPU's point of view means that 0V = a logical 0 and 5V = a logical 1. Or, in programming terms, a 0 = False and a 1 = True. Remember that every command we issue is ultimately turned into an electrical signal composed of Low (0V) and High(5V) pulses.

      |___________________________________________|___________________________________|
    1.7 ms                                                             1.5ms                                                    1.3ms
Counter Clock Wise(Full Speed)                                                  Stop                                                  Clock Wise (Full Speed)
PULSOUT = 850                                                               PULSOUT = 750                                                  PULSOUT = 650


 
  • Calculate how long to run servos:

To run both servos it takes about 24.6ms for a loop to run. Therefore, the number of pulses to send = Time(sec)/.0246
Let's say you want the servos to run for 3 seconds.

Num Pulses = 3/.0246 = 122. So you would use a Loop like this:

FOR counter = 1 to 122

PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20

NEXT

  • Calculate Distance To Move

When programming the BOE-Bot we often want to make it move a specific distance or to execute a particular turn. To do so, we need to figure out the circumference of the wheel (C = 2r). The BOE-Bot’s wheel radius is about 3.335 cm. Thus, the distance traveled by BOE-Bot with one complete turn of the wheel is approximately 21 cm.

The distance, the BOE-Bot will travel, is controlled by sending the pulses to the servo for the correct amount of time. For example, if the pulsout command is given the value of 850, the servo will turn at about 50 RPM (0.83 revolutions per second). The speed will be:

21 cm/rev × 0.83 rev/sec = 17.5 cm/sec.

Thus, the time required for the BOE-Bot travel 100cm is:

Time = 100cm / 17.5 = 5.7 sec.

 

Because we know the duration of the pulse and the duration of the pause, we can

calculate the time for a single loop:

Loop = 1.3ms +1.7ms + 20ms = 23ms

Thus, the number of loops required is:
N = 5.7 / 23 = 247

.